Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Bram Loquet 72 posts 102 karma points
    Aug 11, 2010 @ 14:52
    Bram Loquet
    0

    How to write $node/data [@alias=$split] in 4.5 schema?

    I have a comma separated string with some properties I want from the childNodes of the currentPage.

    <xsl:for-each select="$currentPage/* [...]">
    <xsl:variable name="split" select="umbraco.library:Split($properties, ',')"/>
      <xsl:variable name="node" select="."/>
    <xsl:for-each select="$split/value">
          <xsl:value-of select="$node/."/>
    </xsl:for-each>
    </xsl:for-each>

    The above code returns 3 times the last propery from properties.

     

    So ... How do I write $node/data [@alias=$split] in the new 4.5 schema?
    $node/$split gives an error

  • Matt Brailsford 2958 posts 15629 karma points MVP 7x c-trib
    Aug 11, 2010 @ 14:54
    Matt Brailsford
    0

    Hi Bram,

    This might work

    <xsl:value-of select="$node/*[name() = .]"/>

    Matt

  • Matt Brailsford 2958 posts 15629 karma points MVP 7x c-trib
    Aug 11, 2010 @ 14:57
    Matt Brailsford
    0

    If not, maybe try putting the current value in a var first

    <xsl:variable name="myVar" select="." />
    <
    xsl:value-of select="$node/*[name() = $myVar]"/>

    Matt

  • Bram Loquet 72 posts 102 karma points
    Aug 11, 2010 @ 15:12
    Bram Loquet
    0

    hmm, thought you solutions would be right Matt, but none of them return a value,
    but $node and $MyVar do

  • Matt Brailsford 2958 posts 15629 karma points MVP 7x c-trib
    Aug 11, 2010 @ 16:05
    Matt Brailsford
    0

    Hi Bram,

    What values do you get when you output $node and $MyVar

    Matt

  • Sascha Wolter 615 posts 1101 karma points
    Aug 11, 2010 @ 16:16
    Sascha Wolter
    0

    Hi Bram,

    try this:

    <xsl:value-of select="$node/*[name() = current()]" />

    Here's the complete script I tried:

      <xsl:variable name="properties" select="'prop1,prop2'" />
      <xsl:for-each select="$currentPage/*">
        <xsl:value-of select="./@nodeName" /><br />
        <xsl:variable name="split" select="umbraco.library:Split($properties, ',')" />
        <xsl:variable name="node" select="." />
        <textarea style="width: 300px;height: 200px;"><xsl:copy-of select="." /></textarea><br />
        <xsl:for-each select="$split/value">
          &nbsp;&nbsp;Property: <xsl:value-of select="current()" /><br />
          &nbsp;&nbsp;Value: <xsl:value-of select="$node/*[name() = current()]" />
          <br />
        </xsl:for-each>
      </xsl:for-each>

    Just thought that might come in handy sometime. ;) Hope it works for you,
    Sascha

  • Bram Loquet 72 posts 102 karma points
    Aug 11, 2010 @ 16:44
    Bram Loquet
    0

    for one reason I always get the same value for $node

    when I make a new xslt file it's ok, I suppose it has something to do with the fact that I use it to make an xml-file

  • This forum is in read-only mode while we transition to the new forum.

    You can continue this topic on the new forum by tapping the "Continue discussion" link below.

Please Sign in or register to post replies